home *** CD-ROM | disk | FTP | other *** search
- Path: bmtlh10.bnr.ca!news
- From: John Hickin <hickin@bnr.ca>
- Newsgroups: comp.lang.c++
- Subject: Re: MFC ASSERT_VALID
- Date: 29 Mar 1996 17:51:35 GMT
- Organization: Bell Northern Research
- Message-ID: <4jh7v7$6k@bmtlh10.bnr.ca>
- References: <315C185D.6B46@garlic.com>
- NNTP-Posting-Host: bmtlh520.bnr.ca
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1 (X11; I; HP-UX A.09.05 9000/715)
- X-URL: news:315C185D.6B46@garlic.com
-
- { // This doesn't...
- CAge* pCAge = (CAge*) new char[1 * sizeof(CAge)]; //1
- pCAge[0] = CAge(21); //2
- ASSERT(pCAge[0] == CAge(21)); // OK
- ASSERT_VALID(&pCAge[0]); // AfxIsValidAddress fails:
- // "illegal vtable pointer"
- delete[] (char*)pCAge;
- }
-
- This can't work because the statement //1 does not initialize the memory
- returned by new The CAge constructor is never called. So you think
- you have a valid initialized CAge instance when you don't.
-
- Now the statement //2 is set up to fail because operator= assumes that
- the LHS is properly initialized.
-
-
- --
- John Hickin Nortel Technology, Montreal, Quebec
- (514) 765-7924 hickin@nortel.ca
-
-